
/**
 * Record pre-insert trigger.
 * Validate the record to be inserted.
 * When false is returned the record will not be inserted in the database.
 * When an exception is thrown the record will also not be inserted in the database but it will be added to databaseManager.getFailedRecords(),
 * the thrown exception can be retrieved via record.exception.getValue().
 *
 * @param {JSRecord<db:/cepario/paciente_clinica>} record record that will be inserted
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"74928659-6CCC-4D34-BFF0-A8185AD56163"}
 */
function onRecordInsert_paciente_clinica(record) 
{
	if (record.paciente_clinica_to_clinica)
	{
		if (record.paciente_clinica_to_clinica.tipo == scopes.globals.zconf_entero)
			record.resultado = utils.numberFormat(record.resp_integer,'###,##0'); 
		if (record.paciente_clinica_to_clinica.tipo == scopes.globals.zconf_numerico)
			record.resultado = utils.numberFormat(record.resp_number,'###,##0.00');
		if (record.paciente_clinica_to_clinica.tipo == scopes.globals.zconf_lista)
			record.resultado = record.resp_vl;
		if (record.paciente_clinica_to_clinica.tipo == scopes.globals.zconf_texto)
			record.resultado = record.resp_txt;
		if (record.paciente_clinica_to_clinica.tipo == scopes.globals.zconf_media)
			record.resultado = record.resp_media;
	}
	return true;
}

/**
 * Record pre-update trigger.
 * Validate the record to be updated.
 * When false is returned the record will not be updated in the database.
 * When an exception is thrown the record will also not be updated in the database but it will be added to databaseManager.getFailedRecords(),
 * the thrown exception can be retrieved via record.exception.getValue().
 *
 * @param {JSRecord<db:/cepario/paciente_clinica>} record record that will be updated
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"C09DAD39-2039-4838-B5B6-FC967483FB84"}
 */
function onRecordUpdate_paciento_analisis(record) 
{
	if (record.paciente_clinica_to_clinica)
	{
		if (record.paciente_clinica_to_clinica.tipo == scopes.globals.zconf_entero)
			record.resultado = utils.numberFormat(record.resp_integer,'###,##0'); 
		if (record.paciente_clinica_to_clinica.tipo == scopes.globals.zconf_numerico)
			record.resultado = utils.numberFormat(record.resp_number,'###,##0.00');
		if (record.paciente_clinica_to_clinica.tipo == scopes.globals.zconf_lista)
			record.resultado = record.resp_vl;
		if (record.paciente_clinica_to_clinica.tipo == scopes.globals.zconf_texto)
			record.resultado = record.resp_txt;
		if (record.paciente_clinica_to_clinica.tipo == scopes.globals.zconf_media)
			record.resultado = record.resp_media;
	}
	return true;
}
